package com.stormrage.entity.exam.rep;

import java.io.Serializable;

import com.stormragetech.core.exception.StormrageTechException;
import com.stormragetech.core.util.StrUtil;
import com.stormrage.entity.exam.ExmExam;

public class ExmExamRep implements Serializable {

	// ------------------------------- Fields -------------------------------

	private static final long serialVersionUID = -7257157951709093816L;

	// ------------------------------- Fields -------------------------------

	public Integer seq;

	private Integer id;

	private String question;

	private String type;

	private String relateType;

	private String relateName;

	private Integer count;

	// ------------------------------- Fields -------------------------------

	public ExmExamRep() {
	}

	// ------------------------------- Fields -------------------------------

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getQuestion() {
		return question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getRelateType() {
		return relateType;
	}

	public void setRelateType(String relateType) {
		this.relateType = relateType;
	}

	public String getRelateName() {
		return relateName;
	}

	public void setRelateName(String relateName) {
		this.relateName = relateName;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	// ------------------------------- Fields -------------------------------

	public static ExmExamRep instance(ExmExam arg0, Integer seq, Integer count, String relateName)
			throws StormrageTechException {
		ExmExamRep entity = new ExmExamRep();
		entity.setSeq(seq);
		entity.setId(arg0.getId());
		entity.setQuestion(arg0.getQuestion().length() > 10 ? (StrUtil.cutStr(arg0.getQuestion(), 10) + "...")
				: arg0.getQuestion());

		if (arg0.getType().equals(1))
			entity.setType("单选题");
		if (arg0.getType().equals(2))
			entity.setType("多选题");
		if (arg0.getType().equals(3))
			entity.setType("判断题");

		if (arg0.getRelateType().equals(0))
			entity.setRelateType("课程");
		if (arg0.getRelateType().equals(1))
			entity.setRelateType("课组");

		entity.setRelateName(relateName);
		entity.setCount(count);
		return entity;
	}

	@Override
	public String toString() {
		return this.getClass() + " : id - " + id + " question - " + question + " type - " + type + " relateType - "
				+ relateType + " relateName - " + relateName + " count - " + count;
	}

}
